package com.servlets;

import com.listeners.BindListener;
import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;

import java.io.IOException;

@WebServlet("/servlet1")
public class servlet1 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ServletContext servletContext = getServletContext();
        servletContext.setAttribute("keya","valuea");

        HttpSession session = req.getSession();
        session.setAttribute("keys","values1");
        session.setAttribute("keys","values2");
        session.removeAttribute("keys");


        req.setAttribute("keyr","valuer1");
        req.setAttribute("keyr","valuer2");
        req.removeAttribute("keyr");

        BindListener bindListener = new BindListener();
        session.setAttribute("bl1",bindListener);
        session.removeAttribute("bl1");
    }
}
